package ac.leedsmet.devmanager;

import ac.leedsmet.devmanager.core.*;
import ac.leedsmet.devmanager.guiApp.AgileRequirementsManagement;
import ac.leedsmet.devmanager.guiApp.CreateIssueDialog;
import ac.leedsmet.devmanager.guiApp.CreateUserDialog;
import ac.leedsmet.devmanager.guiApp.DevManagerAboutBox;
import org.jdesktop.application.*;
import org.jdesktop.application.Action;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 * The application's main frame.
 * @author Mike
 * @author Samael
 */
public class DevManagerView extends FrameView {

    protected static Project project = null;
    public static final ProjectManagerImpl pM = new ProjectManagerImpl();
    public static final UserManagerImpl userManager = new UserManagerImpl();

    private static StoryManagerImpl storyManager;
    private static IssueManagerImpl issueManager;

    public static ProjectManagerImpl getProjectManager() {
        return pM;
    }

    public static UserManagerImpl getUserManager() {
        return userManager;
    }

    public static void setCurrentProject(Project project) {
        DevManagerView.project = project;
        storyManager = new StoryManagerImpl(project);
        issueManager = new IssueManagerImpl(project);
    }

    public static StoryManagerImpl getStoryManager() {
        return storyManager;
    }

    public static IssueManagerImpl getIssueManager() {
        return issueManager;
    }

    public static Project getCurrentProject() {
        return project;
    }

    public DevManagerView(SingleFrameApplication app) {
        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = DevManagerApp.getApplication().getMainFrame();
            aboutBox = new DevManagerAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        DevManagerApp.getApplication().show(aboutBox);
    }


//        final JFileChooser proj_fc = new JFileChooser();
//    proj_fc.setAcceptAllFileFilterUsed(false);  // Limit to our Project files
//    FileFilter devFilter = createFileFilter("DevManager Project Files",
//                showExtensionInDescription, "dev");
//    proj_fc.addChoosableFileFilter(devFilter);
//
//    int returnVal = proj_fc.showOpenDialog(null);

    public void showCreateProjectDialog()
    {

//        if (createProjectDialog == null) {
//            JFrame mainFrame = DevManagerApp.getApplication().getMainFrame();
//            createProjectDialog = new CreateProjectDialog(mainFrame, true);
//            createProjectDialog.setLocationRelativeTo(mainFrame);
//        }
//        DevManagerApp.getApplication().show(createProjectDialog);
//        if (createProjectDialog != null){
//            projectName = createProjectDialog.getReturnStatus();
//        }
    }

    public void showCreateIssueDialog() {
        if (createIssueDialog == null) {
            JFrame mainFrame = DevManagerApp.getApplication().getMainFrame();
            createIssueDialog = new CreateIssueDialog(mainFrame, true);
            createIssueDialog.setLocationRelativeTo(mainFrame);
        }
        DevManagerApp.getApplication().show(createIssueDialog);
    }

    public void showCreateUserDialog() {
        if (createUserDialog == null) {
            JFrame mainFrame = DevManagerApp.getApplication().getMainFrame();
            createUserDialog = new CreateUserDialog(mainFrame, true);
            createUserDialog.setLocationRelativeTo(mainFrame);
        }
        DevManagerApp.getApplication().show(createUserDialog);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Main_Panel = new javax.swing.JPanel();
        Main_ToolBar = new javax.swing.JToolBar();
        NewDialog_Button = new javax.swing.JButton(new ImageIcon("cut.gif"));
        OpenDialog_Button = new javax.swing.JButton();
        SaveDialog_Button = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        AgileReqMgt_Button = new javax.swing.JButton();
        BugTrack_Button = new javax.swing.JButton();
        CodeDesignRev_Button = new javax.swing.JButton();
        TestPlan_Button = new javax.swing.JButton();
        ProjDocs_Button = new javax.swing.JButton();
        JobControl_Button = new javax.swing.JButton();
        DevMgr_MenuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu File_Menu = new javax.swing.JMenu();
        NewMenu = new javax.swing.JMenu();
        NewProject = new javax.swing.JMenuItem();
        OpenMenu = new javax.swing.JMenu();
        OpenProject = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        SaveProject = new javax.swing.JMenuItem();
        SaveAllProjects = new javax.swing.JMenuItem();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        Edit_Menu = new javax.swing.JMenu();
        Tools_Menu = new javax.swing.JMenu();
        AgileReqMngmt = new javax.swing.JMenuItem();
        BugTrack_MenuItem = new javax.swing.JMenuItem();
        CodeDesignRev_MenuItem = new javax.swing.JMenuItem();
        TestPlan_MenuItem = new javax.swing.JMenuItem();
        ProjDocs_MenuItem = new javax.swing.JMenuItem();
        JobControl_MenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu Help_Menu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        Status_Panel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        Main_Panel.setMaximumSize(new java.awt.Dimension(1024, 750));
        Main_Panel.setName("Main_Panel"); // NOI18N
        Main_Panel.setPreferredSize(new java.awt.Dimension(1024, 750));

        Main_ToolBar.setRollover(true);
        Main_ToolBar.setName("Main_ToolBar"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ac.leedsmet.devmanager.DevManagerApp.class).getContext().getResourceMap(DevManagerView.class);
        NewDialog_Button.setText(resourceMap.getString("NewDialog_Button.text")); // NOI18N
        NewDialog_Button.setFocusable(false);
        NewDialog_Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        NewDialog_Button.setName("NewDialog_Button"); // NOI18N
        Main_ToolBar.add(NewDialog_Button);

        OpenDialog_Button.setText(resourceMap.getString("OpenDialog_Button.text")); // NOI18N
        OpenDialog_Button.setFocusable(false);
        OpenDialog_Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        OpenDialog_Button.setName("OpenDialog_Button"); // NOI18N
        Main_ToolBar.add(OpenDialog_Button);

        SaveDialog_Button.setText(resourceMap.getString("SaveDialog_Button.text")); // NOI18N
        SaveDialog_Button.setFocusable(false);
        SaveDialog_Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        SaveDialog_Button.setName("SaveDialog_Button"); // NOI18N
        Main_ToolBar.add(SaveDialog_Button);

        jSeparator1.setName("jSeparator1"); // NOI18N
        Main_ToolBar.add(jSeparator1);

        AgileReqMgt_Button.setFocusable(false);
        AgileReqMgt_Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        AgileReqMgt_Button.setLabel(resourceMap.getString("AgileReqMgt_Button.label")); // NOI18N
        AgileReqMgt_Button.setName("AgileReqMgt_Button"); // NOI18N
        AgileReqMgt_Button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        AgileReqMgt_Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AgileReqMgt_ButtonActionPerformed(evt);
            }
        });
        Main_ToolBar.add(AgileReqMgt_Button);

        BugTrack_Button.setText(resourceMap.getString("BugTrack_Button.text")); // NOI18N
        BugTrack_Button.setFocusable(false);
        BugTrack_Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BugTrack_Button.setName("BugTrack_Button"); // NOI18N
        BugTrack_Button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Main_ToolBar.add(BugTrack_Button);

        CodeDesignRev_Button.setText(resourceMap.getString("CodeDesignRev_Button.text")); // NOI18N
        CodeDesignRev_Button.setFocusable(false);
        CodeDesignRev_Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        CodeDesignRev_Button.setName("CodeDesignRev_Button"); // NOI18N
        CodeDesignRev_Button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Main_ToolBar.add(CodeDesignRev_Button);

        TestPlan_Button.setText(resourceMap.getString("TestPlan_Button.text")); // NOI18N
        TestPlan_Button.setFocusable(false);
        TestPlan_Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        TestPlan_Button.setName("TestPlan_Button"); // NOI18N
        TestPlan_Button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Main_ToolBar.add(TestPlan_Button);

        ProjDocs_Button.setText(resourceMap.getString("ProjDocs_Button.text")); // NOI18N
        ProjDocs_Button.setFocusable(false);
        ProjDocs_Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        ProjDocs_Button.setName("ProjDocs_Button"); // NOI18N
        ProjDocs_Button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Main_ToolBar.add(ProjDocs_Button);

        JobControl_Button.setText(resourceMap.getString("JobControl_Button.text")); // NOI18N
        JobControl_Button.setFocusable(false);
        JobControl_Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JobControl_Button.setName("JobControl_Button"); // NOI18N
        JobControl_Button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Main_ToolBar.add(JobControl_Button);

        javax.swing.GroupLayout Main_PanelLayout = new javax.swing.GroupLayout(Main_Panel);
        Main_Panel.setLayout(Main_PanelLayout);
        Main_PanelLayout.setHorizontalGroup(
            Main_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Main_ToolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 779, Short.MAX_VALUE)
        );
        Main_PanelLayout.setVerticalGroup(
            Main_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Main_PanelLayout.createSequentialGroup()
                    .addComponent(Main_ToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(604, Short.MAX_VALUE))
        );

        DevMgr_MenuBar.setName("DevMgr_MenuBar"); // NOI18N

        File_Menu.setText(resourceMap.getString("File_Menu.text")); // NOI18N
        File_Menu.setName("File_Menu"); // NOI18N

        NewMenu.setActionCommand(resourceMap.getString("NewMenu.actionCommand")); // NOI18N
        NewMenu.setLabel(resourceMap.getString("NewMenu.label")); // NOI18N
        NewMenu.setName("NewMenu"); // NOI18N

        NewProject.setText(resourceMap.getString("NewProject.text")); // NOI18N
        NewProject.setName("NewProject"); // NOI18N
        NewProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NewProjectActionPerformed(evt);
            }
        });
        NewMenu.add(NewProject);

        File_Menu.add(NewMenu);
        NewMenu.getAccessibleContext().setAccessibleName(resourceMap.getString("NewMenuItem.AccessibleContext.accessibleName")); // NOI18N

        OpenMenu.setText(resourceMap.getString("OpenMenu.text")); // NOI18N
        OpenMenu.setActionCommand(resourceMap.getString("OpenMenu.actionCommand")); // NOI18N
        OpenMenu.setName("OpenMenu"); // NOI18N

        OpenProject.setText(resourceMap.getString("OpenProject.text")); // NOI18N
        OpenProject.setActionCommand(resourceMap.getString("OpenProject.actionCommand")); // NOI18N
        OpenProject.setName("OpenProject"); // NOI18N
        OpenProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OpenProjectActionPerformed(evt);
            }
        });
        OpenMenu.add(OpenProject);

        File_Menu.add(OpenMenu);
        OpenMenu.getAccessibleContext().setAccessibleName(resourceMap.getString("OpenMenuItem.AccessibleContext.accessibleName")); // NOI18N

        jSeparator2.setName("jSeparator2"); // NOI18N
        File_Menu.add(jSeparator2);

        SaveProject.setText(resourceMap.getString("SaveProject.text")); // NOI18N
        SaveProject.setActionCommand(resourceMap.getString("SaveProject.actionCommand")); // NOI18N
        SaveProject.setName("SaveProject"); // NOI18N
        SaveProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveProjectActionPerformed(evt);
            }
        });
        File_Menu.add(SaveProject);

        SaveAllProjects.setText(resourceMap.getString("SaveAllProjects.text")); // NOI18N
        SaveAllProjects.setName("SaveAllProjects"); // NOI18N
        SaveAllProjects.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveAllProjectsActionPerformed(evt);
            }
        });
        File_Menu.add(SaveAllProjects);

        javax.swing.ActionMap actionMap = Application.getInstance(DevManagerApp.class).getContext().getActionMap(DevManagerView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        File_Menu.add(exitMenuItem);

        DevMgr_MenuBar.add(File_Menu);

        Edit_Menu.setText(resourceMap.getString("Edit_Menu.text")); // NOI18N
        Edit_Menu.setName("Edit_Menu"); // NOI18N
        DevMgr_MenuBar.add(Edit_Menu);

        Tools_Menu.setText(resourceMap.getString("Tools_Menu.text")); // NOI18N
        Tools_Menu.setName("Tools_Menu"); // NOI18N
        Tools_Menu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Tools_MenuActionPerformed(evt);
            }
        });

        AgileReqMngmt.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        AgileReqMngmt.setActionCommand(resourceMap.getString("AgileReqMngmt.actionCommand")); // NOI18N
        AgileReqMngmt.setLabel(resourceMap.getString("AgileReqMngmt.label")); // NOI18N
        AgileReqMngmt.setName("AgileReqMngmt"); // NOI18N
        AgileReqMngmt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AgileReqMngmtActionPerformed(evt);
            }
        });
        Tools_Menu.add(AgileReqMngmt);

        BugTrack_MenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        BugTrack_MenuItem.setText(resourceMap.getString("BugTrack_MenuItem.text")); // NOI18N
        BugTrack_MenuItem.setActionCommand(resourceMap.getString("BugTrack_MenuItem.actionCommand")); // NOI18N
        BugTrack_MenuItem.setName("BugTrack_MenuItem"); // NOI18N
        Tools_Menu.add(BugTrack_MenuItem);

        CodeDesignRev_MenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        CodeDesignRev_MenuItem.setText(resourceMap.getString("CodeDesignRev_MenuItem.text")); // NOI18N
        CodeDesignRev_MenuItem.setActionCommand(resourceMap.getString("CodeDesignRev_MenuItem.actionCommand")); // NOI18N
        CodeDesignRev_MenuItem.setName("CodeDesignRev_MenuItem"); // NOI18N
        Tools_Menu.add(CodeDesignRev_MenuItem);

        TestPlan_MenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        TestPlan_MenuItem.setText(resourceMap.getString("TestPlan_MenuItem.text")); // NOI18N
        TestPlan_MenuItem.setActionCommand(resourceMap.getString("TestPlan_MenuItem.actionCommand")); // NOI18N
        TestPlan_MenuItem.setName("TestPlan_MenuItem"); // NOI18N
        Tools_Menu.add(TestPlan_MenuItem);

        ProjDocs_MenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        ProjDocs_MenuItem.setText(resourceMap.getString("ProjDocs_MenuItem.text")); // NOI18N
        ProjDocs_MenuItem.setActionCommand(resourceMap.getString("ProjDocs_MenuItem.actionCommand")); // NOI18N
        ProjDocs_MenuItem.setName("ProjDocs_MenuItem"); // NOI18N
        Tools_Menu.add(ProjDocs_MenuItem);

        JobControl_MenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_J, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        JobControl_MenuItem.setText(resourceMap.getString("JobControl_MenuItem.text")); // NOI18N
        JobControl_MenuItem.setActionCommand(resourceMap.getString("JobControl_MenuItem.actionCommand")); // NOI18N
        JobControl_MenuItem.setName("JobControl_MenuItem"); // NOI18N
        Tools_Menu.add(JobControl_MenuItem);

        DevMgr_MenuBar.add(Tools_Menu);

        Help_Menu.setText(resourceMap.getString("Help_Menu.text")); // NOI18N
        Help_Menu.setName("Help_Menu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        Help_Menu.add(aboutMenuItem);

        DevMgr_MenuBar.add(Help_Menu);

        Status_Panel.setName("Status_Panel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout Status_PanelLayout = new javax.swing.GroupLayout(Status_Panel);
        Status_Panel.setLayout(Status_PanelLayout);
        Status_PanelLayout.setHorizontalGroup(
            Status_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 779, Short.MAX_VALUE)
            .addGroup(Status_PanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(statusMessageLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 609, Short.MAX_VALUE)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(statusAnimationLabel)
                    .addContainerGap())
        );
        Status_PanelLayout.setVerticalGroup(
            Status_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Status_PanelLayout.createSequentialGroup()
                    .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(Status_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(statusMessageLabel)
                            .addComponent(statusAnimationLabel)
                            .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(3, 3, 3))
        );

        setComponent(Main_Panel);
        setMenuBar(DevMgr_MenuBar);
        setStatusBar(Status_Panel);
        setToolBar(Main_ToolBar);
    }

    private void Tools_MenuActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here: Call Stories Window
    }

    private void AgileReqMngmtActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:

        AgileRequirementsManagement frame = new AgileRequirementsManagement(this);
        frame.setVisible(true);
        Main_Panel.add(frame);
        try {
            frame.setSelected(true);
        } catch (java.beans.PropertyVetoException e) {}
    }

    private void AgileReqMgt_ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
        AgileRequirementsManagement frame = new AgileRequirementsManagement(this);
        frame.setVisible(true);
        Main_Panel.add(frame);
        try {
            frame.setSelected(true);
        } catch (java.beans.PropertyVetoException e) {}
    }//GEN-LAST:event_AgileReqMgt_ButtonActionPerformed

    private void NewProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewProjectActionPerformed
// TODO Need 
        //          final CreateProjectDialog pDialog = new CreateProjectDialog(this, true);

        showCreateProjectDialog();

//    boolean showExtensionInDescription = true;
//    final JFileChooser proj_fc = new JFileChooser();
//    proj_fc.setAcceptAllFileFilterUsed(false);  // Limit to our Project files
//    FileFilter devFilter = createFileFilter("DevManager Project Files",
//                showExtensionInDescription, "dev");
//    proj_fc.addChoosableFileFilter(devFilter);
//
//    int returnVal = proj_fc.showOpenDialog(null);
//    if(returnVal == JFileChooser.APPROVE_OPTION) 
//    {
//       proj_fc.getSelectedFile().getName();
//       ProjectManagerImpl projMgr = new ProjectManagerImpl();
//       Project project = projMgr.createProject(proj_fc.getSelectedFile().getName());
//       setCurrentProject(project);
//       // TODO set the program frame title to getName()
//       
////           jTextField1.setText(fc.getCurrentDirectory() + "\\" + proj_fc.getSelectedFile().getName());
//     }

    }

    private void SaveProjectActionPerformed(ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void SaveAllProjectsActionPerformed(ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void OpenProjectActionPerformed(ActionEvent evt) {
        // TODO add your handling code here:
        boolean showExtensionInDescription = true;
        final JFileChooser proj_fc = new JFileChooser();
        proj_fc.setAcceptAllFileFilterUsed(false);  // Limit to our Project files
        FileFilter devFilter = createFileFilter("DevManager Project Files",
                showExtensionInDescription, "dev");
        proj_fc.addChoosableFileFilter(devFilter);

        int returnVal = proj_fc.showOpenDialog(null);
        if(returnVal == JFileChooser.APPROVE_OPTION)
        {
            proj_fc.getSelectedFile().getName();
//       ProjectManagerImpl projMgr = new ProjectManagerImpl();
            //      projMgr = new ProjectManagerImpl();
            project = pM.createProject(proj_fc.getSelectedFile().getName());
            setCurrentProject(project);
            // TODO set the program frame title to getName()
            Main_Panel.setName(proj_fc.getSelectedFile().getName());

//           jTextField1.setText(fc.getCurrentDirectory() + "\\" + proj_fc.getSelectedFile().getName());
            //          final CreateProjectDialog pDialog = new CreateProjectDialog(this, true);
        }
    }

    private FileFilter createFileFilter(String description,
                                        boolean showExtensionInDescription, String... extensions) {
        if (showExtensionInDescription) {
            description = createFileNameFilterDescriptionFromExtensions(
                    description, extensions);
        }
        return new FileNameExtensionFilter(description, extensions);
    }

    private String createFileNameFilterDescriptionFromExtensions(String description, String[] extensions) {
        String fullDescription = (description == null) ? "(" : description
                + " (";
        // build the description from the extension list
        fullDescription += "." + extensions[0];
        for (int i = 1; i < extensions.length; i++) {
            fullDescription += ", .";
            fullDescription += extensions[i];
        }
        fullDescription += ")";
        return fullDescription;
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AgileReqMgt_Button;
    private javax.swing.JMenuItem AgileReqMngmt;
    private javax.swing.JButton BugTrack_Button;
    private javax.swing.JMenuItem BugTrack_MenuItem;
    private javax.swing.JButton CodeDesignRev_Button;
    private javax.swing.JMenuItem CodeDesignRev_MenuItem;
    private javax.swing.JMenuBar DevMgr_MenuBar;
    private javax.swing.JMenu Edit_Menu;
    private javax.swing.JButton JobControl_Button;
    private javax.swing.JMenuItem JobControl_MenuItem;
    private javax.swing.JPanel Main_Panel;
    private javax.swing.JToolBar Main_ToolBar;
    private javax.swing.JButton NewDialog_Button;
    private javax.swing.JMenu NewMenu;
    private javax.swing.JMenuItem NewProject;
    private javax.swing.JButton OpenDialog_Button;
    private javax.swing.JMenu OpenMenu;
    private javax.swing.JMenuItem OpenProject;
    private javax.swing.JButton ProjDocs_Button;
    private javax.swing.JMenuItem ProjDocs_MenuItem;
    private javax.swing.JMenuItem SaveAllProjects;
    private javax.swing.JButton SaveDialog_Button;
    private javax.swing.JMenuItem SaveProject;
    private javax.swing.JPanel Status_Panel;
    private javax.swing.JButton TestPlan_Button;
    private javax.swing.JMenuItem TestPlan_MenuItem;
    private javax.swing.JMenu Tools_Menu;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
    private JDialog createProjectDialog;
    private JDialog createUserDialog;
    private JDialog createIssueDialog;
}
